import axios from 'axios';
import { React, useRef } from 'react'
export default function UploadImg() {
    const file = useRef();
    const submit = useRef();
    function submitFile() {
        let formData = new FormData();
        formData.append("header",file.current.files[0]);
        let config = {
            headers: { "Content-Type": "multipart/form-data" }
          };
        axios.post('http://localhost:3000/upload/',formData,config).then((res)=>{
            console.log(res);
        })
    }
    return (
        <div>
            <form>
                <input type="file" ref={file} />
                <br />
                <input type="button" value="通过普通按钮提交" onClick={submitFile} ref={submit} />
            </form>
        </div>
    )
}
